<template>
	<view>
		<bg-video></bg-video>
		<cu-custom bgColor="bg-purple" :isBack="true">
			<block class="text-white" slot="content">课程列表</block>
		</cu-custom>
		
		<!-- 门店教练课程列表 -->
		<view>
			<view class="padding-xs">
				<view class="bg-white shadow radius margin-bottom-xs" v-for="(kc,index) in kcs" :key="index">
					<kc-item :path="'/pages/cmdjl'" :kc="kc"></kc-item>
				</view>
			</view>
			
			<view v-if="kcs.length < pageInfo.total" class="padding ">
				<button @tap="loadMore" class="cu-btn block bg-purple lg">显示更多</button>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data: function() {
			return {
				mdjlid: "",
				kcs: [],
				pageInfo: {
					current: 1,
					size: 16,
					total: 0
				}
			}
		},
		onLoad: function() {
			this.mdjlid = this.store.state.mdjl.mdjlid;
			this.search();
		},
		methods: {
			search: function() {
				this.kcs = [];
				this.pageInfo.current = 1;
				this.loadKcs();
			},
			loadMore: function() {
				this.pageInfo.current++;
				this.loadKcs();
			},
			loadKcs: function() {
				let param = {
					current: this.pageInfo.current,
					size: this.pageInfo.size,
					mdjlid: this.mdjlid,
				};
				this.api("/kc/page").send(param).then(data => {
					this.pageInfo.current = data.akechengs.current;
					for (let index in data.akechengs.records) {
						let record = data.akechengs.records[index];
						this.kcs.push(record);
					}
				});
			}
		}
	}
</script>

<style>
</style>